<template>
  <div style="">
    <Header :left="true" leftText="返回" title="未按时复核加严"></Header>
  
      <!-- 未确认页面 -->
 
        <div class="textScroll">
          <!-- 循环数据开始 -->
          <div v-for="(item, index) in itemsOne" :key="item.Id" style="position: relative">
            <div style="width: 100%; background-color: #f3f4f8; height: 5px">
              <span></span>
            </div>
            <div class="divStyle">
              <van-row style="margin-left: 10px; margin-top: 10px" v-show="false">
                <van-col span="6"><b>id:</b></van-col>
                <van-col span="14">{{ item.Id }}</van-col>
              </van-row>
              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="6"><b>序号:</b></van-col>
                <van-col span="14">{{ index + 1 }}</van-col>
              </van-row>
              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="6"><b>生产线:</b></van-col>
                <van-col span="14">{{ item.PLineID }}</van-col>
              </van-row>

              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="8"><b>加严活动标记:</b></van-col>
                <!-- <van-col span="12" style="color: red;">{{ showActive(item.Active) }}</van-col> -->
                <van-col span="12" style="color: red;">是</van-col>
              </van-row>


              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="6"><b>建议等级:</b></van-col>
                <van-col span="14">{{ showABCTypeName(item.ABCType) }}</van-col>
              </van-row>

              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="6"><b>判定时间:</b></van-col>
                <van-col span="14">{{ item.ComfirmDatetime }}</van-col>
              </van-row>

              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="6"><b>判定人:</b></van-col>
                <van-col span="14">{{ item.ComfirmMan }}</van-col>
                <van-col span="2">
                  <van-button color="#138087" @click.stop="seeDetail(item)" style="
                      width: 85px;
                      height: 40px;
                      font-size: 12px;
                      position: absolute;
                      left: 70%;
                    " type="primary" text="详情" />
                </van-col>
              </van-row>

              <van-row style="margin-left: 10px; margin-top: 10px">
                <van-col span="6"><b>加严类型:</b></van-col>
                <van-col span="14">{{
                  showAddStrictTypeName(item.StrictTypeID)
                }}</van-col>
              </van-row>
              <van-row style="
                  margin-left: 10px;
                  margin-top: 10px;
                  border-bottom: 2px solid rgba(82, 76, 76, 0.39);
                ">
                <van-col span="6"> </van-col>
                <van-col span="3"> </van-col>
                <van-col span="6"> </van-col>
              </van-row>
            </div>
          </div>
        </div>


  </div>
</template>
  
<script>
import {
  Col,
  Row,
  Form,
  Cell,
  Icon,
  Field,
  tab,
  tabs,
  NumberKeyboard,
  Image as VanImage,
  Picker,
  popup,
  SubmitBar,
  Button,
  Loading,
  Overlay,
  Dialog,
  Toast,
  NoticeBar,
  Tag,
  DatetimePicker,
  ImagePreview,
  CellGroup,
  Uploader,
  Cascader,
  Calendar,
  RadioGroup,
  Radio,
  Divider,
  Stepper,
  AddressList,
  Checkbox,
  CheckboxGroup,
} from "vant";

import "vue-easytable/libs/themes-base/index.css";
import { VTable } from "vue-easytable";
import { _httpClient } from "@/libs/apisie";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { _httpClient as _httpClientApisie } from "@/libs/apisie";
import Header from "@/components/header.vue";
import { storage } from "@/libs/utils";

Vue.use(Form);
Vue.use(Field);
Vue.use(Overlay);
Vue.use(Loading);
Vue.use(Picker);
Vue.use(popup);
Vue.use(SubmitBar);
Vue.use(VanImage);
Vue.use(DatetimePicker);
Vue.use(Cascader);
Vue.use(Calendar);
Vue.use(Cell);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Divider);
Vue.use(Stepper);
Vue.use(Button);
Vue.use(AddressList);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Col);
Vue.use(Row);
Vue.use(tab);
Vue.use(tabs);

export default {
  name: "tightsure",
  components: {
    Form,
    Row,
    Col,
    Button,
    Header,
    Form,
    Cell,
    Icon,
    Field,
    NumberKeyboard,
    Dialog,
    Toast,
    NoticeBar,
    Row,
    Tag,
    popup,
    DatetimePicker,
    ImagePreview,
    CellGroup,
    Uploader,
    Col,
    Calendar,
    Cascader,
    Picker,
    RadioGroup,
    Radio,
    Divider,
    Stepper,
    VTable,
    AddressList,
    Checkbox,
    CheckboxGroup,
    tab,
    tabs,
  },
  data() {
    return {
      form: [],
      columnsPOrderID: [],
      columnsStrictTypeID: [
        { StrictTypeID: "SM01", StrictTypeName: "关键工艺参数异常加严" },
        { StrictTypeID: "SM02", StrictTypeName: "机器设备异常加严" },
        { StrictTypeID: "SM03", StrictTypeName: "质量异常加严" },
        { StrictTypeID: "SM04", StrictTypeName: "生产条件异常加严" },
      ],
      itemsOne: [],
      itemsTwo: [],
      columnsABCType: [
        { ABCType: "1", ABCTypeName: "甲" },
        { ABCType: "2", ABCTypeName: "乙" },
        { ABCType: "3", ABCTypeName: "丙" },
        { ABCType: "4", ABCTypeName: "-未确定" },
      ],
    };
  },
  created: function () {
    let oldHight = api.winWidth;
    this.screenWidth = oldHight;
    //获取当前系统登录用户
    this.user = JSON.parse(storage.get("user"));
    this.user.userId = this.user.userName;
    this.getLeaderUncheckedList();
    this.getPOrderID();
  },
  mounted() {

    
   },

  methods: {
    showPOrderIDName(POrderID) {
      var POrderIDName = POrderID;
      this.columnsPOrderID.forEach((item) => {
        if (item.POrderID === POrderID) {
          POrderIDName = item.POrderIDAndMaterialName;
        }
      });
      return POrderIDName;
    },
    async getPOrderID() {
      let _this = this;
      try {
        let res = await _httpClientApisie.get(
          _httpClientApisie.getApiPrefix() + "/ProductionOrder/GetList"
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            POrderID: item.POrderID,
            MaterialName: item.MaterialName,
            MaterialID: item.MaterialID,
            POrderIDAndMaterialName: item.POrderID + " " + item.MaterialName,
          }));
          _this.columnsPOrderID = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    showAddStrictTypeName(AddStrictType) {
      var AddStrictTypeName = AddStrictType;
      this.columnsStrictTypeID.forEach((item) => {
        if (item.StrictTypeID === AddStrictType) {
          AddStrictTypeName = item.StrictTypeName;
        }
      });
      return AddStrictTypeName;
    },
    convertlevel(val) {
      if (val == "1") {
        return "甲";
      }
      if (val == "2") {
        return "乙";
      }
      if (val == "3") {
        return "丙";
      }
    },
    showABCTypeName(ABCType) {
      var ABCTypeName = ABCType;
      this.columnsABCType.forEach((item) => {
        if (item.ABCType === ABCType) {
          ABCTypeName = item.ABCTypeName;
        }
      });
      return ABCTypeName;
    },
    showActive(val) {
      // if (val != "1") {
      //   return "否";
      // } else {
      //   return "是";
      // }

      return val;
    },
    seeDetail(item) {
      let _this = this;
      api.openWin({
        reload: true,
        name: "showActivedTightfill",
        url: "./tightenup-showActivedTightfill.html",
        pageParam: {
          item: item.Id,
        },
      });
      
    },
    async getLeaderUncheckedList() {     
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });        

      let _this = this;
      try {
        let res = await _httpClientApisie.get(
          _httpClientApisie.getApiPrefix() +
          "/AddStrictManage/GetList?NoDoOnTime=true"
        );
     
        //alert(JSON.stringify(res.Data));
        Toast.clear();
        _this.itemsOne = res.Data;
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取品管领班已审核记录
    async getLeaderCheckedList() {
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });    
      let _this = this;
      try {
        let res = await _httpClientApisie.get(
          _httpClientApisie.getApiPrefix() +
          "/AddStrictManage/GetList?Processed=true"
        );

        Toast.clear();
        _this.itemsTwo = res.Data;
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    async submitsure() { },
    tabChange(name, title) {
      if (name == 0) {
        this.itemsOne = [];
        //查询未审核信息
        this.getLeaderUncheckedList();
      } else if (name == 1) {
        //查询已审核信息
        this.itemsTwo = [];
        this.getLeaderCheckedList();
      }
    },
  },
};
</script>
  
<style>
body {
  background-color: white;
}
</style>
  